<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\SearchHouseModel */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="house-model-index">


    <?php echo $this->render('index_search', ['model' => $searchModel]); ?>
	
	<!--<input type="text" class="span2" placeholder="关键字">
	<button type="submit" class="btn btn-success" style="margin-left: 20px;">搜索</button>-->
	
	<br>

    <p>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'options' => ['class' => 'grid-view','style'=>'overflow:auto', 'id' => 'grid'],
        'columns' => [
            'house_name',
            'developer',
			[
                'class' => 'yii\grid\RadioButtonColumn',
                'name' =>'id',
                'radioOptions' => function ($model) {
		             return [
		                 'value' => $model['id'],
		                 'checked' => $model['id'] == 2,
		                 'id' => $model['id'],
		                 'data-hname'=>$model['house_name'],
		             ];
		         }               
            ]
        ],
        'pager' => [
	    	'options'=>['class'=>"pagination",'name'=>'pageid'],
	    ],
    ]);

	$this->registerJs('$(":radio").on("click", function () {
		    var keys = $(this).attr("id");
		    var hname = $(this).attr("data-hname");
		    console.log(keys);
		    $("#housename").attr("value",hname);
		    $("#houseidname").attr("value",keys);
		    
	});');
	
	$requestUrl = Url::toRoute('/house/index-select');
	$this->registerJs("$('a').each(function(){
    	var href = $(this).attr('href','#');
    	var pages = parseInt($(this).attr('data-page'))+1;
    	$(this).click(function(){
		    
		    var topage = '?page='+pages;
			
			console.log('topage='+topage);
		    $.get('{$requestUrl}'+topage, {},
	            function (data) {
	                $('.modal-body').html(data);
	            }  
	        );
		    
		});
    	//console.log(href);
	});");
    ?>
    
</div>
